﻿using CodeGenerator.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;

namespace CodeGenerator
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
            Sunisoft.IrisSkin.SkinEngine skin = new Sunisoft.IrisSkin.SkinEngine();
            try
            {
                FileInfo[] files = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, "Skins"))
                               .GetFiles("*.ssk", SearchOption.AllDirectories);
                Random ran = new Random();
               int  sskindex= ran.Next(0, files.Count()+1);
                string ssk = files[sskindex].Name;
               skin.SkinFile = Application.StartupPath + "//Skins//"+ ssk;
            }
            catch (Exception)
            {

            }
            this.StartPosition = FormStartPosition.CenterScreen;
        }
        private frmLeft frmleft = new frmLeft();
        private void frmleft_newcontentForm(Connection conModel, string tableName, string databaseName, bool isView)
        {
            new frmContent
            {
                Text = "(" + databaseName + ")" + tableName,
                TableName = tableName,
                DatabaseName = databaseName,
                IsView = isView,
                ConnectionModel = conModel
            }.Show(this.dpleft);
        }
        private void frmMain_Load(object sender, EventArgs e)
        {
            frmleft.newcontentForm += new frmLeft.NewContentForm(this.frmleft_newcontentForm);
            frmleft.Show(dpleft, DockState.DockLeft);
            frmWelcome frmwelcome = new frmWelcome();
            frmwelcome.Show(dpleft, DockState.Document);
        }
    }
}
